import React from 'react';
import style from './style.css'
import {Button} from 'antd'
import {getHistory} from "../../util/uitls";

class DingyiPay extends React.Component {
    constructor(props) {
        super()
        this.state = {}

    }


    componentDidMount() {
    }


    render() {
        var self = this
        var isNoEnmony = parseFloat(this.props.myPrice) > parseFloat(this.props.goodPrice)
        return <div className={style.dingyiModal}>
            <div className={style.myMoeny}>你的余额:￥{this.props.myPrice}</div>
            <div className={style.imageWrapper}>
                <img src="/static/dingyipay.png" alt=""/>
            </div>
            <div className={style.thisPrice}>
                本次交易应付金额: <span className={style.strong}>￥{this.props.goodPrice}</span>
            </div>
            <div className={style.btnWrapper}>
                {isNoEnmony && <Button className={style.queding}
                                       onClick={() => {
                                           self.props.onSuccess()
                                       }}
                >确认支付</Button>}
                {isNoEnmony && <Button className={style.quxiao}
                                       onClick={() => {
                                           self.props.onCancel()
                                       }}
                >取消</Button>}
                {!isNoEnmony && <Button className={style.onEneny} onClick={() => {
                    getHistory().push('/setting/finance-center')
                }
                }>账号余额不足，前往充值</Button>}
            </div>
        </div>
    }
}

DingyiPay.defaultProps = {
    myPrice: 0,
    goodPrice: 0,
    onCancel() {
    },
    onSuccess() {
    }
}

export default DingyiPay;